﻿using System.ServiceModel;
using Sinacor.Infra.Service.Security.Services;
using Sinacor.Servico.Bovespa.ContasCorrente.BusinessEntity;
using System.Collections.Generic;

namespace Sinacor.Servico.Bovespa.ContasCorrente.Service.ServiceImplementation
{
    /// <summary>
    /// LLiez.7Comm
    /// Adequação - alteração Atributo Behavior
    /// Data: 08/08/2008
    /// </summary>
    [SinacorServiceBehavior]
    public class ContasCorrente : Sinacor.Servico.Bovespa.ContasCorrente.Service.ServiceContract.IContasCorrente
    {
        /// <summary>
        /// Historico:
        /// Data : 18/12/2007
        /// Autor: Ludmilla Modesto 
        /// Obs.: Criado. Metodo que retorna o codigo do Cliente na atividade de Contas Correntes
        /// </summary>
        /// <returns></returns>
        public DataContract.Response.PosicaoContasCorrenteResponse
            ConsultarPosicaoContasCorrente(DataContract.Request.ConsultarPosicaoContaCorrenteRequest request)
        {
            Sinacor.Servico.Bovespa.Cliente.BusinessEntity.Cliente beCliente = 
                Translator.TranslateBetweenConsultarPosicaoContaCorrenteRequestAndCliente.
                TranslateConsultarPosicaoContaCorrenteRequestToCliente(request);

            Sinacor.Servico.Bovespa.ContasCorrente.BusinessLogic.ContasCorrente blContasCorrente = new BusinessLogic.ContasCorrente();

            BusinessEntity.PosicaoContasCorrente contaCorrente = 
                blContasCorrente.ConsultarPosicaoContasCorrente(beCliente);

            return  Translator.TranslateBetweenPosicaoContasCorrenteResponseAndPosicaoContasCorrente.
                TranslatePosicaoContasCorrenteToPosicaoContasCorrenteResponse(contaCorrente);
        }

        public List<DataContract.Response.HistoricoContaCorrenteResponse> ConsultarHistoricoContasCorrentes(DataContract.Request.FiltroHistoricoContaCorrenteRequest request)
        {
            List<BusinessEntity.HistoricoContaCorrente> _entities = new List<BusinessEntity.HistoricoContaCorrente>();

            Translator.DataContractToBusinessEntity.ContaCorrente _translatorDataContractToBusinessEntity = new Sinacor.Servico.Bovespa.ContasCorrente.Service.ServiceImplementation.Translator.DataContractToBusinessEntity.ContaCorrente();

            BusinessLogic.ContasCorrente _businessLogic = new Sinacor.Servico.Bovespa.ContasCorrente.BusinessLogic.ContasCorrente();

            _entities = _businessLogic.ConsultarHistoricoContasCorrentes(_translatorDataContractToBusinessEntity.ToFiltroHistoricoContaCorrente(request));

            Translator.BusinessEntityToDataContract.ContaCorrente _translatorBusinessEntityToDataContract = new Sinacor.Servico.Bovespa.ContasCorrente.Service.ServiceImplementation.Translator.BusinessEntityToDataContract.ContaCorrente();

            return _translatorBusinessEntityToDataContract.ToHistoricoContaCorrenteResponse(_entities);
        }
    }
}
